package com.ljsw.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ljsw.activity.R;
import com.ljsw.entity.gpk.StockLive;

import java.util.List;

/**
 * Created by lianchao on 2020/10/15.
 */

public class PKMoneyInfoAdapter extends BaseAdapter {

    private List<StockLive> LockID;
    private Context mContext;

    public PKMoneyInfoAdapter(List<StockLive> LockID, Context mContext) {
        super();
        this.LockID = LockID;
        this.mContext = mContext;
    }


    @Override
    public int getCount() {
        return LockID.size();
    }

    @Override
    public Object getItem(int position) {
        return LockID.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        PKMoneyInfoAdapter.ViewHolder mviewHolder = null;
        if (mviewHolder == null) {
            mviewHolder = new PKMoneyInfoAdapter.ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.pkmoney_info_list_item, null, false);
            TextView PKNo = (TextView) convertView.findViewById(R.id.pkmoney_info_no);
            TextView tvtime = (TextView) convertView.findViewById(R.id.pkmoney_info_no2);
            TextView tvstate = (TextView) convertView.findViewById(R.id.pkmoney_info_no3);
            TextView pkmoney_info_no4 = (TextView) convertView.findViewById(R.id.pkmoney_info_no4);
            mviewHolder.PKNo = PKNo;
            mviewHolder.tvtime = tvtime;
            mviewHolder.tvstate = tvstate;
            mviewHolder.pkmoney_info_no4 = pkmoney_info_no4;
            convertView.setTag(mviewHolder);
        } else {
            mviewHolder = (PKMoneyInfoAdapter.ViewHolder) convertView.getTag();
            convertView.setTag(mviewHolder);
        }
        mviewHolder.PKNo.setText(LockID.get(position).getCoupon() + ""); //面值
        mviewHolder.tvtime.setText(LockID.get(position).getCurrency());
        if (LockID.get(position).getCoupontype().equals("1")) {
            mviewHolder.tvstate.setText(" 完整券");
        } else if (LockID.get(position).getCoupontype().equals("2")) {
            mviewHolder.tvstate.setText(" 完损券");
        } else if (LockID.get(position).getCoupontype().equals("3")) {

            mviewHolder.tvstate.setText(" 半损券");
        }

//           // 金额
        mviewHolder.pkmoney_info_no4.setText(LockID.get(position).getMoney() + "");

//         券种 3种： "1" : "完整券"
//                        , "2" : "完损券"
        return convertView;
    }


    class ViewHolder {
        private TextView PKNo;
        private TextView tvtime;
        private TextView tvstate;
        private TextView pkmoney_info_no4;


    }
}
